package com.jifen.dynamic.controller;

import com.jifen.common.CommonParam;
import com.jifen.common.CommonResult;
import com.jifen.common.Result;
import com.jifen.dynamic.service.DynamicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/jf/{version}/dynamic")
public class DynamicController {

    @Autowired
    DynamicService dynamicService;

    /**
     * 列表
     * @param param
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Result getDynamic(CommonParam param, HttpServletRequest request) {
        String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/h5/dynamic/detail?id=";
        return CommonResult.createSuccessResult(dynamicService.getDynamic(param, url));
    }

    /**
     * 详情
     * @param id
     * @return
     */
    @RequestMapping("/detail")
    @ResponseBody
    public Result detail(int id) {
        return CommonResult.createSuccessResult(dynamicService.detail(id));
    }

}
